/**
 * Copyright &copy; 2015-2020 <a href="http://www.suifeng.org/">jeeplus</a> All rights reserved.
 */
package com.portal.admin.utils.admin;


import com.portal.admin.dict.entity.SysDict;
import com.portal.admin.office.entity.SysOffice;

import java.util.List;
import java.util.stream.Collectors;

import static com.portal.admin.base.cache.service.SysCacheService.dictMap;

/**
 * 字典工具类
 */
public class DictUtils {

	public static List<SysOffice> getOfficeList(){
//		List<SysOffice> officeList = (List<SysOffice>) EhCacheUtils.get(ROLE_USER_OFFICE);
		return null;
	}

	public static String getDictLabel(String dictType,Object value){
		List<SysDict> dictList = (List<SysDict>) dictMap.get(dictType);
		SysDict dict = dictList.stream().filter(item -> value.equals(item.getValue())).collect(Collectors.toList()).get(0);
		return dict.getLabel();
	}

	public static String getDictValue(String dictType,String label){
		List<SysDict> dictList = (List<SysDict>) dictMap.get(dictType);
		SysDict dict = dictList.stream().filter(item -> label.equals(item.getLabel())).collect(Collectors.toList()).get(0);
		return dict.getValue();
	}
}
